package com.surfilter.massdata.spark.util.ipcheck;

import java.util.Date;

import com.surfilter.massdata.spark.bean.ipcheck.ActiveIp;
import com.surfilter.massdata.spark.bean.ipcheck.BeianAllocate;
import com.surfilter.massdata.spark.bean.ipcheck.BeianSource;
import com.surfilter.massdata.spark.bean.ipcheck.ErrorIpSeg;
import com.surfilter.massdata.spark.bean.ipcheck.IpBean;
import com.surfilter.massdata.spark.bean.ipcheck.UploadAllocate;
import com.surfilter.massdata.spark.bean.ipcheck.UploadSource;

/** 
* @author  hutao
* @date 创建时间：2017年5月22日 下午3:21:55 
* @Description：
* @version 1.0 
* 
**/
public class IpConvertUtil {
	public static IpBean convertIpBean(String[] ipArr, IpBean ipBean){
		ipBean.setId(Long.valueOf(ipArr[0]));
		ipBean.setBbdw_id(Long.valueOf(ipArr[1]));
		if("null".equals(ipArr[2])){
			ipBean.setSbsj(-1l);
		}else{
			ipBean.setSbsj(Long.valueOf(ipArr[2]));
		}
		if("null".equals(ipArr[3])){
			ipBean.setIplx(-1);
		}else{
			ipBean.setIplx(Integer.valueOf(ipArr[3]));
		}
		ipBean.setQsip(Long.valueOf(ipArr[4]));
		ipBean.setZzip(Long.valueOf(ipArr[5]));
		if("null".equals(ipArr[6])){
			ipBean.setSfgn(-1l);
		}else{
			ipBean.setSfgn(Long.valueOf(ipArr[6]));
		}
		if("null".equals(ipArr[7])){
			ipBean.setFpfs(-1l);
		}else{
			ipBean.setFpfs(Long.valueOf(ipArr[7]));
		}
		if("null".equals(ipArr[8])){
			ipBean.setFpdx(-1l);
		}else{
			ipBean.setFpdx(Long.valueOf(ipArr[8]));
		}
		if("null".equals(ipArr[9])){
			ipBean.setSyfs(-1l);
		}else{
			ipBean.setSyfs(Long.valueOf(ipArr[9]));
		}
		if("null".equals(ipArr[10])){
			ipBean.setFprq(-1l);
		}else{
			ipBean.setFprq(Long.valueOf(ipArr[10]));
		}
		if("null".equals(ipArr[11])){
			ipBean.setYmtzfwq(-1);
		}else{
			ipBean.setYmtzfwq(Integer.valueOf(ipArr[11]));
		}
		if("null".equals(ipArr[12])){
			ipBean.setDwmc("N/A");
		}else{
			ipBean.setDwmc(ipArr[12]);
		}
		if("null".equals(ipArr[13])){
			ipBean.setDwxz(-1l);
		}else{
			ipBean.setDwxz(Long.valueOf(ipArr[13]));
		}
		if("null".equals(ipArr[14])){
			ipBean.setDwxzjb(-1l);
		}else{
			ipBean.setDwxzjb(Long.valueOf(ipArr[14]));
		}
		if("null".equals(ipArr[15])){
			ipBean.setDwfl(-1l);
		}else{
			ipBean.setDwfl(Long.valueOf(ipArr[15]));
		}
		if("null".equals(ipArr[16])){
			ipBean.setDwhyfl(-1l);
		}else{
			ipBean.setDwhyfl(Long.valueOf(ipArr[16]));
		}
		if("null".equals(ipArr[17])){
			ipBean.setJyxkzh("N/A");
		}else{
			ipBean.setJyxkzh(ipArr[17]);
			
		}
		if("null".equals(ipArr[18])){
			ipBean.setShengid(-1l);
		}else{
			ipBean.setShengid(Long.valueOf(ipArr[18]));
			
		}
		if("null".equals(ipArr[19])){
			ipBean.setShiid(-1l);
		}else{
			ipBean.setShiid(Long.valueOf(ipArr[19]));
			
		}
		if("null".equals(ipArr[20])){
			ipBean.setXianid(-1l);
		}else{
			ipBean.setXianid(Long.valueOf(ipArr[20]));
			
		}
		if("null".equals(ipArr[21])){
			ipBean.setXxdz("N/A");
		}else{
			ipBean.setXxdz(ipArr[21]);
			
		}
		if("null".equals(ipArr[22])){
			ipBean.setLxrxm("N/A");
		}else{
			ipBean.setLxrxm(ipArr[22]);
		}
		if("null".equals(ipArr[23])){
			ipBean.setLxrdh("N/A");
		}else{
			ipBean.setLxrdh(ipArr[23]);
		}
		if("null".equals(ipArr[24])){
			ipBean.setLxrdzyj("N/A");
		}else{
			ipBean.setLxrdzyj(ipArr[24]);
		}
		if("null".equals(ipArr[25])){
			ipBean.setWgip(-1l);
		}else{
			ipBean.setWgip(Long.valueOf(ipArr[25]));
		}
		if("null".equals(ipArr[26])){
			ipBean.setWgdz("N/A");
		}else{
			ipBean.setWgdz(ipArr[26]);
		}
		if("null".equals(ipArr[27])){
			ipBean.setBz("N/A");
		}else{
			ipBean.setBz(ipArr[27]);
		}
		if("null".equals(ipArr[28])){
			ipBean.setIpsss(-1l);
		}else{
			ipBean.setIpsss(Long.valueOf(ipArr[28]));
		}
		if("null".equals(ipArr[29])){
			ipBean.setJtiplx(-1);
		}else{
			ipBean.setJtiplx(Integer.valueOf(ipArr[29]));
		}
		if("null".equals(ipArr[30])){
			ipBean.setIpssjf("N/A");
		}else{
			ipBean.setIpssjf(ipArr[30]);
		}
		if("null".equals(ipArr[31])){
			ipBean.setLyid(-1l);
		}else{
			ipBean.setLyid(Long.valueOf(ipArr[31]));
		}
		if("null".equals(ipArr[32])){
			ipBean.setSourceIdcId("N/A");
		}else{
			ipBean.setSourceIdcId(ipArr[32]);
		}
		if("null".equals(ipArr[33])){
			ipBean.setReportIdcId("N/A");
		}else{
			ipBean.setReportIdcId(ipArr[33]);
		}
		if("null".equals(ipArr[34])){
			ipBean.setReportType(-1);
		}else{
			ipBean.setReportType(Integer.valueOf(ipArr[34]));
		}
		if("null".equals(ipArr[35])){
			ipBean.setLastModifyTime(-1l);
		}else{
			ipBean.setLastModifyTime(Long.valueOf(ipArr[35]));
		}
		if("null".equals(ipArr[36])){
			ipBean.setIsWarn(-1);
		}else{
			ipBean.setIsWarn(Integer.valueOf(ipArr[36]));
		}
		if("null".equals(ipArr[37])){
			ipBean.setStorageType("N/A");
		}else{
			ipBean.setStorageType(ipArr[37]);
		}
		if("null".equals(ipArr[38])){
			ipBean.setTflag("N/A");
		}else{
			ipBean.setTflag(ipArr[38]);
		}
		if("null".equals(ipArr[39])){
			ipBean.setIsPass(true);
		}else{
			ipBean.setIsPass(Boolean.valueOf(ipArr[39]));
		}
		if("null".equals(ipArr[40])){
			ipBean.setConflictType(-1);
		}else{
			ipBean.setConflictType(Integer.valueOf(ipArr[40]));
		}
		if("null".equals(ipArr[41])){
			ipBean.setHouseCode("N/A");
		}else{
			ipBean.setHouseCode(ipArr[41]);
		}
		if("null".equals(ipArr[42])){
			ipBean.setLylx(-1);
		}else{
			ipBean.setLylx(Integer.parseInt(ipArr[42]));
		}
		if("null".equals(ipArr[43])){
			ipBean.setFpLyId(-1l);
		}else{
			ipBean.setFpLyId(Long.parseLong(ipArr[43]));
		}
		if("null".equals(ipArr[44])){
			ipBean.setLymc("N/A");
		}else{
			ipBean.setLymc(ipArr[44]);
		}
		
		
		return ipBean;
	}
	
	public static BeianSource convertIpBeanToBeianSource(IpBean ipBean){
		BeianSource beianSource = new BeianSource();
		beianSource.setId(ipBean.getId());
		beianSource.setBbdwId(ipBean.getBbdw_id());
		beianSource.setLydw(ipBean.getLyid());
		beianSource.setQsip(ipBean.getQsip());
		beianSource.setZzip(ipBean.getZzip());
		beianSource.setBz(ipBean.getBz());
		beianSource.setStorageType(ipBean.getStorageType());
		beianSource.setTfFlag(ipBean.getTflag());
		beianSource.setFindTime(new Date().getTime());
		return beianSource;
	}
	
	public static UploadSource convertIpBeanToUploadSource(IpBean ipBean){
		UploadSource us = new UploadSource();
		us.setId(ipBean.getId());
		us.setBbdwId(ipBean.getBbdw_id());
		us.setLydw(ipBean.getLyid());
		us.setQsip(ipBean.getQsip());
		us.setZzip(ipBean.getZzip());
		us.setBz(ipBean.getBz());
		us.setSourceIdcId(ipBean.getSourceIdcId());
		us.setReportIdcId(ipBean.getReportIdcId());
		us.setReportType(ipBean.getReportType());
		us.setLastModifyTime(ipBean.getLastModifyTime());
		us.setIsWarn(ipBean.getIsWarn());
		us.setFindTime(new Date().getTime());
		us.setStorageType(ipBean.getStorageType());
		us.setTfFlag(ipBean.getTflag());
		return us;
	}
	
	public static BeianAllocate convertIpBeanToBeianAllocate(IpBean ipBean){
		BeianAllocate allocate = new BeianAllocate();
		allocate.setId(ipBean.getId());
		allocate.setBbdwId(ipBean.getBbdw_id());
		allocate.setSbsj(ipBean.getSbsj());
		allocate.setIplx(ipBean.getIplx());
		allocate.setQsip(ipBean.getQsip());
		allocate.setZzip(ipBean.getZzip());
		allocate.setSfgn(ipBean.getSfgn());
		allocate.setFpfs(ipBean.getFpfs());
		allocate.setFpdx(ipBean.getFpdx());
		allocate.setSyfs(ipBean.getSyfs());
		allocate.setFprq(ipBean.getFprq());
		allocate.setYmtzfwq(ipBean.getYmtzfwq());
		allocate.setDwmc(ipBean.getDwmc());
		allocate.setDwxz(ipBean.getDwxz());
		allocate.setDwxzjb(ipBean.getDwxzjb());
		allocate.setDwfl(ipBean.getDwfl());
		allocate.setDwhyfl(ipBean.getDwhyfl());
		allocate.setJyxkzh(ipBean.getJyxkzh());
		allocate.setShengid(ipBean.getShengid());
		allocate.setShiid(ipBean.getShiid());
		allocate.setXianid(ipBean.getXianid());
		allocate.setXxdz(ipBean.getXxdz());
		allocate.setLxrxm(ipBean.getLxrxm());
		allocate.setLxrdh(ipBean.getLxrdh());
		allocate.setLxrdzyj(ipBean.getLxrdzyj());
		allocate.setWgip(ipBean.getWgip());
		allocate.setWgdz(ipBean.getWgdz());
		allocate.setBz(ipBean.getBz());
		allocate.setIpsss(ipBean.getIpsss());
		allocate.setJtiplx(ipBean.getJtiplx());
		allocate.setIpssjf(ipBean.getIpssjf());
		allocate.setFindTime(new Date().getTime());
		allocate.setStorageType(ipBean.getStorageType());
		allocate.setTfFlag(ipBean.getTflag());
		allocate.setLylx(ipBean.getLylx());
		allocate.setFpLyId(ipBean.getFpLyId());
		allocate.setLymc(ipBean.getLymc());
		return allocate;
	}
	
	public static UploadAllocate convertIpBeanToUploadAllocate(IpBean ipBean){
		UploadAllocate allocate = new UploadAllocate();
		allocate.setId(ipBean.getId());
		allocate.setBbdwId(ipBean.getBbdw_id());
		allocate.setSbsj(ipBean.getSbsj());
		allocate.setQsip(ipBean.getQsip());
		allocate.setZzip(ipBean.getZzip());
		allocate.setSfgn(ipBean.getSfgn());
		allocate.setFpfs(ipBean.getFpfs());
		allocate.setFpdx(ipBean.getFpdx());
		allocate.setSyfs(ipBean.getSyfs());
		allocate.setFprq(ipBean.getFprq());
		allocate.setYmtzfwq(ipBean.getYmtzfwq());
		allocate.setDwmc(ipBean.getDwmc());
		allocate.setDwxz(ipBean.getDwxz());
		allocate.setDwxzjb(ipBean.getDwxzjb());
		allocate.setDwfl(ipBean.getDwfl());
		allocate.setDwhyfl(ipBean.getDwhyfl());
		allocate.setJyxkzh(ipBean.getJyxkzh());
		allocate.setShengid(ipBean.getShengid());
		allocate.setShiid(ipBean.getShiid());
		allocate.setXianid(ipBean.getXianid());
		allocate.setXxdz(ipBean.getXxdz());
		allocate.setLxrxm(ipBean.getLxrxm());
		allocate.setLxrdh(ipBean.getLxrdh());
		allocate.setLxrdzyj(ipBean.getLxrdzyj());
		allocate.setWgip(ipBean.getWgip());
		allocate.setWgdz(ipBean.getWgdz());
		allocate.setBz(ipBean.getBz());
		allocate.setIpsss(ipBean.getIpsss());
		allocate.setJtiplx(ipBean.getJtiplx());
		allocate.setIpssjf(ipBean.getIpssjf());
		
		allocate.setSourceIdcId(ipBean.getSourceIdcId());
		allocate.setReportIdcId(ipBean.getReportIdcId());
		allocate.setReportType(ipBean.getReportType());
		allocate.setLastModifyTime(ipBean.getLastModifyTime());
		allocate.setIsWarn(ipBean.getIsWarn());
		
		
		allocate.setHouseCode(ipBean.getHouseCode());
		allocate.setIplx(ipBean.getIplx());
		allocate.setFindTime(new Date().getTime());
		
		allocate.setStorageType(ipBean.getStorageType());
		allocate.setTfFlag(ipBean.getTflag());
		
		allocate.setLylx(ipBean.getLylx());
		allocate.setFpLyId(ipBean.getFpLyId());
		allocate.setLymc(ipBean.getLymc());
		
		return allocate;
	}
	
	public static IpBean copy(IpBean newIpBean, IpBean iterBean){
		newIpBean.setId(iterBean.getId());
		newIpBean.setBbdw_id(iterBean.getBbdw_id());
		newIpBean.setSbsj(iterBean.getSbsj());
		newIpBean.setIplx(iterBean.getIplx());
		newIpBean.setQsip(iterBean.getQsip());
		newIpBean.setZzip(iterBean.getZzip());
		newIpBean.setSfgn(iterBean.getSfgn());
		newIpBean.setFpfs(iterBean.getFpfs());
		newIpBean.setFpdx(iterBean.getFpdx());
		newIpBean.setSyfs(iterBean.getSyfs());
		newIpBean.setFprq(iterBean.getFprq());
		newIpBean.setYmtzfwq(iterBean.getYmtzfwq());
		newIpBean.setDwmc(iterBean.getDwmc());
		newIpBean.setDwxz(iterBean.getDwxz());
		newIpBean.setDwxzjb(iterBean.getDwxzjb());
		newIpBean.setDwfl(iterBean.getDwfl());
		newIpBean.setDwhyfl(iterBean.getDwhyfl());
		newIpBean.setJyxkzh(iterBean.getJyxkzh());
		newIpBean.setShengid(iterBean.getShengid());
		newIpBean.setShiid(iterBean.getShiid());
		newIpBean.setXianid(iterBean.getXianid());
		newIpBean.setXxdz(iterBean.getXxdz());
		newIpBean.setLxrxm(iterBean.getLxrxm());
		newIpBean.setLxrdh(iterBean.getLxrdh());
		newIpBean.setLxrdzyj(iterBean.getLxrdzyj());
		newIpBean.setWgip(iterBean.getWgip());
		newIpBean.setWgdz(iterBean.getWgdz());
		newIpBean.setBz(iterBean.getBz());
		newIpBean.setIpsss(iterBean.getIpsss());
		newIpBean.setJtiplx(iterBean.getJtiplx());
		newIpBean.setIpssjf(iterBean.getIpssjf());
		newIpBean.setLyid(iterBean.getLyid());
		newIpBean.setSourceIdcId(iterBean.getSourceIdcId());
		newIpBean.setReportIdcId(iterBean.getReportIdcId());
		newIpBean.setReportType(iterBean.getReportType());
		newIpBean.setLastModifyTime(iterBean.getLastModifyTime());
		newIpBean.setIsWarn(iterBean.getIsWarn());
		newIpBean.setStorageType(iterBean.getStorageType());
		newIpBean.setTflag(iterBean.getTflag());
		newIpBean.setIsPass(iterBean.getIsPass());
		newIpBean.setConflictType(iterBean.getConflictType());
		newIpBean.setHouseCode(iterBean.getHouseCode());
		newIpBean.setLylx(iterBean.getLylx());
		newIpBean.setFpLyId(iterBean.getFpLyId());
		newIpBean.setLymc(iterBean.getLymc());
		return newIpBean;
		
	}
	
	public static ErrorIpSeg copy(ErrorIpSeg newSeg, ErrorIpSeg iterSeg){
		newSeg.setQsip(iterSeg.getQsip());
		newSeg.setZzip(iterSeg.getZzip());
		newSeg.setBbdws(iterSeg.getBbdws());
		newSeg.setConflictType(iterSeg.getConflictType());
		newSeg.setRegionIds(iterSeg.getRegionIds());
		newSeg.setStorageType(iterSeg.getStorageType());
		return newSeg;
	}
	
	public static IpBean convertActiveIp2IpBean(IpBean newBean, ActiveIp ipSeg){
		newBean.setId(ipSeg.getKeyTime());
		newBean.setQsip(ipSeg.getIpLong());
		newBean.setZzip(ipSeg.getIpLong());
		newBean.setSyfs(-1l);
		newBean.setHouseCode(ipSeg.getHouseCode());
		newBean.setBbdw_id(ipSeg.getBbdwId());
		newBean.setStorageType(IpCheckConstants.ACTIVEIP);
		return newBean;
	}
	
	public static ActiveIp copyActiveIp(ActiveIp ip){
		ActiveIp newIp = new ActiveIp();
		newIp.setBbdwId(ip.getBbdwId());
		newIp.setIpLong(ip.getIpLong());
		newIp.setQsip(ip.getQsip());
		newIp.setZzip(ip.getZzip());
		newIp.setHouseCode(ip.getHouseCode());
		newIp.setKeyTime(ip.getKeyTime());
		newIp.setJson(ip.getJson());
		return newIp;
	}
	

}
